/**
 * Created by DELL on 2017/5/8.
 */
(function() {
    'use strict';
    var checkedObject = {};
    common.buildNormalEnumSelect(".isAuth", enumObject.enumJsonData['isAuth']);
    /**
     * 中介联系人 列表初始化设置
     * @type {Object}
     */
    var settings = {
        "sAjaxSource": window.globalHost + common.agentListPort,
        "aoColumns": [
            {
                "mDataProp": function (obj) {
                    return enumObject.enumJsonData['isAuth'][obj.isAuth];
                },
                "sTitle": "审核状态",
                "sDefaultContent": ""
            },
            {
                "mDataProp": function (obj) {
                    return obj.agentName===""?"无姓名":obj.agentName;
                },
                "sTitle": "姓名",
                "sDefaultContent": ""
            }, {
                "mDataProp": function(obj) {
                    return obj.mobile===""?"无信息":obj.mobile;
                },
                "sTitle": "手机号码",
                "sDefaultContent": ""
            }, {
                "mDataProp": function (obj) {
                    return obj.companyName===""?"无信息":obj.companyName;
                },
                "sTitle": "所属公司",
                "sDefaultContent": ""
            }, {
                "mDataProp": function (obj) {
                    return obj.storeName===""?"无信息":obj.storeName;
                },
                "sTitle": "所属门店",
                "sDefaultContent": ""
            }, {
                "mDataProp": function (obj) {
                    return obj.createTime===""?"无信息":obj.createTime===undefined?"undefined":obj.createTime;
                },
                "sTitle": "创建时间",
                "sDefaultContent": ""
            }, {
                "mDataProp": function (obj) {
                    return obj.authTime===""?"尚未审核":obj.authTime===undefined?"undefined":obj.authTime;
                },
                "sTitle": "审核时间",
                "sDefaultContent": ""
            }, {
                "mDataProp": function (obj) {
                    if(obj.isAuth>0){
                        return '<button type="button" class="btn btn-success btn-xs btn-block show-info" data-id="' + obj.id + '">查看详情</button>';
                    }else {
                        return '';
                    }
                },
                "sTitle": "操作",
                "sDefaultContent": ""
            }
        ],
        "fnServerParams": function(aoData) {
            return common.getSearchData("form.data-list-search",aoData);
        }
    };
    var options = $.extend(true, {}, _dataTableSettings, settings);
    /**
     * 实例化 中介联系人 列表插件
     * @type {[type]}
     */
    var $currentDataTable=$("#data-list");
    var oTable = $currentDataTable.dataTable(options);
    searchList.getDataList(oTable);
    searchList.resetSearch(oTable);

    $currentDataTable.off("click").on("click",".show-info",function (ev) {
        var $this=$(this);
        var selfId=$this.attr("data-id");
        common.openInsertDialog({
            title:'注册信息详情',
            url:"./loginManage/dataInfo.html?agentId="+selfId,
            btn:[],
            // 'sAjaxSource': window.globalHost + common.agentUpdatePort,
            'area': ['1000px', '600px'],
            ok: function() {
                //  新增信息成功之后，刷新列表页面
                // oTable.fnClearTable();
            },
            cancel: function() {}
        });
        ev.stopPropagation();
    });

}).call(this);